<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="*|/"><xsl:apply-templates/></xsl:template>

<xsl:template match="text()|@*"><xsl:value-of select="."/></xsl:template>

<xsl:template match='nbsp' name='nbsp'>
<xsl:text disable-output-escaping='yes'>&amp;nbsp;</xsl:text>
</xsl:template>

<xsl:include href='xsl.include.main.xsl'/>

  <xsl:template name="buddy">
    <tr>
      
      <td align="left" style="border-bottom:1px solid white;">

        <nobr>
          <xsl:call-template name="user">
            <xsl:with-param name="status" select="@uStatus"/>
            <xsl:with-param name="sexid" select="@sexid"/>
            <xsl:with-param name="certified" select="@certified"/>
            <xsl:with-param name="userid" select="@userid"/>
            <xsl:with-param name="nick" select="@nick"/>
            <xsl:with-param name="bold" select="0"/>
            <xsl:with-param name="buddy" select="0"/>
            <xsl:with-param name="newbie" select="0"/>
          </xsl:call-template>
        </nobr>

      </td>
     
      <td align="left" style="border-bottom:1px solid white;" class="b10b">

        <xsl:variable name="userid" select="@userid"/>

        <xsl:choose>
          <xsl:when test='count(/buddies/onlineusers/freak/user[@userid = $userid])'>
            <b>E' online adesso!</b>
          </xsl:when>
          <xsl:when test='@llhh &gt; 72 and @lldd &lt;= 45'>
            <xsl:value-of select="@lldd"/> giorni fa.
          </xsl:when>
          <xsl:when test='@llmi &gt; 120 and @llhh &lt;= 72'>
            <xsl:value-of select="@llhh"/> ore fa.
          </xsl:when>
          <xsl:when test='@llmi &gt; 10 and @llmi &lt;= 120'>
            <xsl:value-of select="@llmi"/> minuti fa.
          </xsl:when>
          <xsl:when test='@llmi &lt;= 10'>
            <b>E' online adesso!</b>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="substring(@lastlogin,9,2)"/>/<xsl:value-of select="substring(@lastlogin,6,2)"/>/<xsl:value-of select="substring(@lastlogin,1,4)"/>
            <!--&#160;<xsl:value-of select="substring(@lastlogin,12,8)"/>
                -->
          </xsl:otherwise>
        </xsl:choose>

      </td>
      <td align="left" style="border-bottom:1px solid white;">
        <xsl:choose>
          <xsl:when test='@sexid="24" or @sexid="26" or @sexid="40" or @sexid="1"'>
            <a class="body_10px_red" href="/mailbox/mailboxWrite.aspx?receiverGuid={@userid}">Scrivigli un messaggio!</a>
          </xsl:when>
          <xsl:when test='@sexid="25" or @sexid="27"'>
            <a class="body_10px_red" href="/mailbox/mailboxWrite.aspx?receiverGuid={@userid}">Scrivile un messaggio!</a>
          </xsl:when>
        </xsl:choose>
      </td>
      <td align="left" style="border-bottom:1px solid white;">
        <a style="color:#006699;" href="/buddies.aspx?del=1&amp;buddy={@userid}">
          <img border="0" src="/imgs/delete.gif"/>
        </a>
      </td>
    </tr>
  </xsl:template>
  
  
<xsl:template match="buddies">
  <div class="round_me" style="background:#FEEECC; padding:10px;">
    <table class="body" border="0" cellspacing="0" cellpadding="4" width="100%">
      <tr>
        <td style="border-bottom:1px solid white;" align="left">
          <b>&#160;&#160;
            
            <xsl:choose>
              <xsl:when test="@order=1">
                 <a href="?order=1">S</a><img src="imgs/arrow_up.gif"></img>
              </xsl:when>
              <xsl:otherwise>
                 <a href="?order=1">S</a>
              </xsl:otherwise>
            </xsl:choose>
            
          </b>
       
          &#160;&#160;
          <xsl:choose>
            <xsl:when test="@order=0">
              <b><a href="?order=0">Nickname</a></b>
              <img src="imgs/arrow_up.gif"></img>
            </xsl:when>
            <xsl:otherwise>
              <b><a href="?order=0">Nickname</a></b>
            </xsl:otherwise>
          </xsl:choose>
          
        </td>
        <td style="border-bottom:1px solid white;" align="left">

          <xsl:choose>
            <xsl:when test="@order=2">
              <b>
                <a href="?order=2">Ultimo login</a>
              </b>
              <img src="imgs/arrow_up.gif"></img>
            </xsl:when>
            <xsl:otherwise>
              <b>
                <a href="?order=2">Ultimo login</a>
              </b>
            </xsl:otherwise>
          </xsl:choose>
        </td>
        <td style="border-bottom:1px solid white;" align="center">&#160;</td>
        <td style="border-bottom:1px solid white;" align="center">&#160;</td>
      </tr>
      
        <xsl:choose>
          <xsl:when test="@order=1">
            <xsl:for-each select="buddy">
              <xsl:sort order="ascending" select="@sexid"/>
              <xsl:call-template name="buddy">
              </xsl:call-template>
            </xsl:for-each>
          </xsl:when>
          <xsl:when test="@order=2">
            <xsl:for-each select="buddy">
              <xsl:sort order="descending" select="@lastlogin"/>
              <xsl:call-template name="buddy">
              </xsl:call-template>
            </xsl:for-each>
          </xsl:when>        
          <xsl:otherwise>
            <xsl:for-each select="buddy">
              <xsl:sort order="ascending" select="@nick"/>
              <xsl:call-template name="buddy">
              </xsl:call-template>
            </xsl:for-each>
          </xsl:otherwise>
        </xsl:choose>

      <xsl:if test="count(buddy)=0">
        <tr>
          <td colspan="5" align="center">La lista e' vuota!</td>
        </tr>
      </xsl:if>
    </table>
  </div>
  
</xsl:template>

</xsl:stylesheet>